//https://leetcode.cn/problems/boats-to-save-people/?envType=daily-question&envId=2024-06-10
class Solution {
public:
    int numRescueBoats(vector<int>& people, int limit) {
        sort(people.begin(),people.end());
        int ret = 0;
        int left = 0,right = people.size()-1;
        while(right>=left){
            if(people[left]+people[right]<=limit){
                left++,right--;
            }else{
                right--;
            }
            ret++;
        }
        return ret;
    }
};